import request from '@/utils/request'
// /admin/product/{page}/{limit} get
export const reqSpuList = ({ page, limit, category3Id }) =>
  request(
    {
      url: `/admin/product/${page}/${limit}`,
      method: 'get',
      params: { category3Id }
    })
// spu信息
export const reqSpu = (spuId) =>
  request({
    url: `/admin/product/getSpuById/${spuId}`,
    method: 'get',
  })
// 品牌下拉框信息 admin/product/baseTrademark/getTrademarkList
export const reqTrademarkList = () =>
  request({
    url: '/admin/product/baseTrademark/getTrademarkList',
    method: 'get'
  })
// 图片信息 admin/product/spuImageList/{spuId}  
export const reqSpuImageList = (spuId) =>
  request({
    url: `/admin/product/spuImageList/${spuId}`,
    method: 'get'
  })
//平台全部销售属性下拉框信息 /admin/product/baseSaleAttrList  
export const reqbaseSaleAttrList = () =>
  request({
    url: '/admin/product/baseSaleAttrList',
    method: 'get'
  })

//修改SPU||添加SPU：对于修改或者添加，携带给服务器参数大致一样的，唯一的区别就是携带的参数是否带id
export const reqAddOrUpdateSpu = (spu) => {
  if (spu.id) {
    return request({ url: '/admin/product/updateSpuInfo', method: 'post', data: spu })
  }
  else {
    return request({ url: '/admin/product/saveSpuInfo', method: 'post', data: spu })
  }
}